// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   HoldingScrPanel.java

package com.boci.clientapp.holding;

import com.boci.clientapp.holding.action.HoldingAction;
import com.boci.clientapp.holding.ui.control.HKMarketPanel;
import com.boci.clientapp.holding.ui.control.HKOptionPanel;
import com.boci.clientapp.holding.ui.control.OtherPanel;
import com.boci.clientapp.holding.ui.control.USMarketPanel;
import com.boci.clientapp.holding.ui.control.USOptionPanel;
import com.boci.clientapp.main.ClientAppLoader;
import com.boci.common.ui.AbstractPanel;
import com.boci.common.util.MessagesConfigurator;
import com.boci.common.util.PerformanceLogger;
import com.boci.common.vo.ResponseVO;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Locale;
import javax.swing.*;
import javax.swing.border.LineBorder;

public class HoldingScrPanel extends AbstractPanel
{

    public HoldingScrPanel(Locale pLocale, String pModuleName, String pScreenName)
    {
        super(pLocale, pModuleName, pScreenName);
        initGUI(pLocale);
        setText(pLocale);
    }

    public int getSelection()
    {
        return cmbHolding.getSelectedIndex();
    }

    public void setText(Locale pLocale)
    {
        super.setText(pLocale);
        setFont(pLocale);
        MessagesConfigurator msgConf = ClientAppLoader.getMessagesConfigurator();
        hkMarketPanel.setText(pLocale);
        usMarketPanel.setText(pLocale);
        hkOptionPanel.setText(pLocale);
        usOptionPanel.setText(pLocale);
        otherPanel.setText(pLocale);
        btnGo.setText(msgConf.getUIMessages("HOLDING.GO", pLocale));
        int intOldIndex = cmbHolding.getSelectedIndex();
        cmbHolding.setModel(new DefaultComboBoxModel(new String[] {
            msgConf.getUIMessages("HOLDING.ALL", pLocale), msgConf.getUIMessages("HOLDING.HKMARKET", pLocale), msgConf.getUIMessages("HOLDING.USMARKET", pLocale), msgConf.getUIMessages("HOLDING.HKOPTION", pLocale), msgConf.getUIMessages("HOLDING.USOPTION", pLocale)
        }));
        cmbHolding.setSelectedIndex(intOldIndex);
    }

    private void setFont(Locale pLocale)
    {
        btnGo.setFont(ClientAppLoader.getPlainButtonFont(pLocale));
        cmbHolding.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
    }

    private void initGUI(Locale pLocale)
    {
        setPreferredSize(null);
        initHeaderPanel();
        initHoldingPanel(pLocale);
        setLayout(new BorderLayout());
        add(headerPanel, "North");
        add(holdingPanel, "Center");
    }

    private void initHoldingPanel(Locale pLocale)
    {
        holdingPanel = new JPanel();
        hkMarketPanel = new HKMarketPanel(pLocale);
        usMarketPanel = new USMarketPanel(pLocale);
        hkOptionPanel = new HKOptionPanel(pLocale);
        usOptionPanel = new USOptionPanel(pLocale);
        otherPanel = new OtherPanel(pLocale);
        JPanel gapPanel = new JPanel();
        gapPanel.setOpaque(false);
        gapPanel.setPreferredSize(new Dimension(0, 15));
        holdingPanel.setOpaque(false);
        holdingPanel.setLayout(new BoxLayout(holdingPanel, 1));
        holdingPanel.add(hkMarketPanel);
        holdingPanel.add(usMarketPanel);
        holdingPanel.add(hkOptionPanel);
        holdingPanel.add(usOptionPanel);
        holdingPanel.add(otherPanel);
        holdingPanel.add(gapPanel);
    }

    private void initHeaderPanel()
    {
        headerPanel = new JPanel();
        cmbHolding = new JComboBox();
        btnGo = new JButton();
        headerPanel.setLayout(null);
        headerPanel.setOpaque(false);
        headerPanel.setPreferredSize(new Dimension(0, 25));
        cmbHolding.setBounds(2, 2, 150, 20);
        cmbHolding.setBorder(new LineBorder(new Color(128, 128, 192), 1, false));
        headerPanel.add(cmbHolding);
        btnGo.setMargin(new Insets(0, 0, 0, 0));
        btnGo.setBounds(155, 2, 22, 20);
        btnGo.setActionCommand("GO");
        btnGo.addActionListener(this);
        headerPanel.add(btnGo);
    }

    public void actionPerformed(ActionEvent e)
    {
        PerformanceLogger.startAppTimer();
        String strActionType = e.getActionCommand();
        HoldingAction holdingAction = new HoldingAction();
        holdingAction.doProcess(getInputValue(strActionType), strActionType);
        PerformanceLogger.stopAppTimer();
        PerformanceLogger.doLog((new StringBuilder()).append("HOLDING_SCREEN.").append(strActionType).toString());
    }

    public void showHoldingTable(int pCmbIndex)
    {
        if(pCmbIndex == 0)
        {
            hkMarketPanel.setVisible(true);
            usMarketPanel.setVisible(true);
            hkOptionPanel.setVisible(true);
            usOptionPanel.setVisible(true);
            otherPanel.setVisible(true);
        } else
        if(pCmbIndex == 1)
        {
            hkMarketPanel.setVisible(true);
            usMarketPanel.setVisible(false);
            hkOptionPanel.setVisible(false);
            usOptionPanel.setVisible(false);
            otherPanel.setVisible(false);
        } else
        if(pCmbIndex == 2)
        {
            hkMarketPanel.setVisible(false);
            usMarketPanel.setVisible(true);
            hkOptionPanel.setVisible(false);
            usOptionPanel.setVisible(false);
            otherPanel.setVisible(false);
        } else
        if(pCmbIndex == 3)
        {
            hkMarketPanel.setVisible(false);
            usMarketPanel.setVisible(false);
            hkOptionPanel.setVisible(true);
            usOptionPanel.setVisible(false);
            otherPanel.setVisible(false);
        } else
        if(pCmbIndex == 4)
        {
            hkMarketPanel.setVisible(false);
            usMarketPanel.setVisible(false);
            hkOptionPanel.setVisible(false);
            usOptionPanel.setVisible(true);
            otherPanel.setVisible(false);
        }
        cmbHolding.setSelectedIndex(pCmbIndex);
    }

    public void refresh()
    {
        String strActionType = "GO";
        cmbHolding.setSelectedIndex(0);
        HoldingAction holdingAction = new HoldingAction();
        holdingAction.doProcess(getInputValue(strActionType), strActionType);
    }

    public void refresh(ResponseVO pResponseVO)
    {
        hkMarketPanel.refresh(pResponseVO);
        usMarketPanel.refresh(pResponseVO);
        hkOptionPanel.refresh(pResponseVO);
        usOptionPanel.refresh(pResponseVO);
        otherPanel.refresh(pResponseVO);
    }

    public HashMap getInputValue(String pActionType)
    {
        return new HashMap();
    }

    public boolean validate(String pActionType)
    {
        return true;
    }

    public void setDefFocus()
    {
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                cmbHolding.requestFocus();
            }
        }
);
    }

    private JPanel headerPanel;
    private JPanel holdingPanel;
    private JComboBox cmbHolding;
    private JButton btnGo;
    private HKMarketPanel hkMarketPanel;
    private USMarketPanel usMarketPanel;
    private HKOptionPanel hkOptionPanel;
    private USOptionPanel usOptionPanel;
    private OtherPanel otherPanel;

}
